#ifndef SUPER_COMMAND_H_
#define SUPER_COMMAND_H_
#include "command.h"
#include "ct_srv_entry.h"
#include <stdint.h>

#pragma pack(1)
namespace Cmd
{
        namespace Super
        {
                //  cmd declaration
                enum
                {
                        CMDIN_STARTUP           = 0x0001,	// server start up cmd
                        CMDIN_FORWARD           = 0x0002,	// transfer cmd to other server
                        CMDIN_SYNC              = 0x0003,
                        CMDIN_ROOM              = 0x0005,
                        CMDIN_ROOMMEDIA         = 0x0006,
                        CMDIN_MONITOR           = 0x0007,       // super与其他服务器之间的monitor相关的指令
                        CMDIN_MEDIARECORD       = 0x0008,
                        CMDIN_ECHOSRV           = 0x0009,       // EchoServer与SuperServer之间的交互
                };

                // subcmd declaration
                enum
                { //CMDIN_STARTUP
                        SCMDIN_STARTUP_REQUEST                  = 0x0001,	// server->super: request start up
                        SCMDIN_STARTUP_RESPONSE                 = 0x0002,	// super->server: start up response
                        SCMDIN_STARTUP_OK                       = 0x0003,	// server->super: i start up ok
                        SCMDIN_STARTUP_SERVERENTRY_NOTIFY_ME    = 0x0004,	// super->server: notify all server entries
                        SCMDIN_STARTUP_SERVERENTRY_NOTIFY_OTHER = 0x0005,	// super->server: notify new server entries
                        SCMDIN_SYNC_TIME                        = 0x0006,	// super->server: notify update time
                        SCMDIN_STARTUP_SUPER_REQUEST            = 0x0007,       // super->super: request start up
                        SCMDIN_STARTUP_SUPER_SUCCESS            = 0x0008,       // super->super: start up success
                        SCMDIN_STARTUP_SUPER_FAILURE            = 0x0009,       // super->super: start up failure
                        SCMDIN_STARTUP_SERVERENTRY_NOTIFY_BY_TYPE       = 0x000A,	// super->super: notify type-server entries
                        SCMDIN_STARTUP_SERVERENTRY_NOTIFY_BY_ID = 0x000B,       // super->super: notify id-server entry
                };
                enum
                { //CMDIN_FORWARD
                        SCMDIN_FORWARD_INNERCMD_By_ID           = 0x0001,	// server->super->server:
                        SCMDIN_FORWARD_INNERCMD_By_TYPE         = 0x0002,	// server->super->server:
                };
                enum
                { //CMDIN_SYNC
                        SCMDIN_SYNC_GATEWAY_LOAD_REQUEST        = 0x0001,
                        SCMDIN_SYNC_GATEWAY_LOAD_RESPONSE       = 0x0002,
                        SCMDIN_SYNC_GATEWAY_LOAD_REMOVE         = 0x0003,
                        SCMDIN_SYNC_SESSION_FUNCTIONALITY_SUPPORT       = 0x0004,
                };
                enum
                { //CMDIN_ROOM
                        SCMDIN_ROOM_REQ_ROOM_LOCATION           = 0x0001,	// roomgateway->roomsuper: request room`s roomserver
                        SCMDIN_ROOM_RES_ROOM_LOCATION           = 0x0002,	
                        SCMDIN_ROOM_DEL_ROOM_LOCATION           = 0x0003,
                        SCMDIN_ROOM_REQ_LOAD                    = 0x0004,	// roomsuper->room
                        SCMDIN_ROOM_RES_LOAD                    = 0x0005,	// room->roomsuper
                        SCMDIN_ROOM_REQ_ROOMMEDIAMAP            = 0x0006,
                        SCMDIN_ROOM_RES_ROOMMEDIAMAP            = 0x0007,
                        SCMDIN_ROOM_ROOMLIST_SYNC_REQ           = 0x0008,       // RoomSuperServer与RoomServer连接成功后 向RoomServer请求房间列表
                        SCMDIN_ROOM_ROOMLIST_SYNC_RES           = 0x0009,       // RoomSuperServer向RoomServer请求房间列表后 RoomServer返回该列表
                        SCMDIN_ROOM_REDISTRIBUTE_ROOM_REQ       = 0x000A,       // RoomSuperServer->RoomServer:请求负载该房间,并恢复动态的备份信息
                        SCMDIN_ROOM_REDISTRIBUTE_ROOM_RES       = 0x000B,       // RoomServer->RoomSuperServer:返回负载宕机恢复的房间
                        SCMDIN_ROOM_UPDATE_USER_ROLE            = 0x000C,
                        SCMDIN_ROOM_RES_INNER_NET_LIST          = 0x000D,
                        SCMDIN_ROOM_EVAL_TIME_NOTIFY            = 0x0010,
                };
                enum
                { //CMDIN_ROOMMEDIA
                        SCMDIN_RMEDIA_HEARTBEAT                 = 0x0000,
                };
                enum
                { //CMDIN_MONITOR
                        SCMDIN_MONITOR_USER_LOCATION_REQ        = 0x0001,       // super->session: 请求某个用户的所在位置
                        SCMDIN_MONITOR_USER_LOCATION_RES        = 0x0002,       // session->super: 返回某个用户的所在位置
                        SCMDIN_MONITOR_GATEWAYSERVER_LOAD_REQ   = 0x0003,       // super->gateway: 请求所有网关的负载信息
                        SCMDIN_MONITOR_GATEWAYSERVER_LOAD_RES   = 0x0004,       // gateway->super: 返回所有网关的负载信息
                        SCMDIN_MONITOR_SESSIONSERVER_LOAD_REQ   = 0x0005,       // super->session: 请求所有会话的负载信息
                        SCMDIN_MONITOR_SESSIONSERVER_LOAD_RES   = 0x0006,       // session->super: 返回所有会话的负载信息
                        SCMDIN_MONITOR_ROOMSERVER_LOAD_REQ      = 0x0007,       // roomsuper->room:请求所有房间服务器的负载信息
                        SCMDIN_MONITOR_ROOMSERVER_LOAD_RES      = 0x0008,       // room->roomsuper:返回所有房间服务器的负载信息
                        SCMDIN_MONITOR_UPDATE_ROOM_USER_ROLE    = 0x0009,       // roomsuper->room:请求更新某个用户的权限
                        SCMDIN_MONITOR_ADD_ROOM_GHOST_old       = 0x000A,       // RoomSuper->RoomServer:向房间内加马甲
                        SCMDIN_MONITOR_DEL_ROOM_GHOST_old       = 0x000B,       // RoomSuper->RoomServer:从房间内删除马甲
                        SCMDIN_MONITOR_DEL_ROOM_GHOST_RES_old   = 0x000C,       // RoomServer->RoomSuper:RoomServer删除后返回删除的用户列表
                        SCMDIN_MONITOR_AUTO_REQ_ADD_ROOM_GHOST_old      = 0x000D,       // RoomServer->RoomSuper:RoomServer请求增加几个鬼
                        SCMDIN_MONITOR_AUTO_RES_ADD_ROOM_GHOST_old      = 0x000E,       // RoomSuper->RoomServer:MonitorServer返回增加几个鬼
                        SCMDIN_MONITOR_AUTO_REQ_DEL_ROOM_GHOST_old      = 0x000F,       // RoomSuper->RoomServer:RoomServer请求减少几个鬼
                        SCMDIN_MONITOR_DEPLOY_LOCK_REQ          = 0x0010,       // RoomSuper->RoomServer:请求锁定待调度的频道
                        SCMDIN_MONITOR_DEPLOY_LOCK_RES          = 0x0011,       // RoomServer->RoomSuper:锁定返回
                        SCMDIN_MONITOR_DEPLOY_LOAD_REQ          = 0x0012,       // RoomSuper->RoomServer:请求新的RoomServer负载该频道
                        SCMDIN_MONITOR_DEPLOY_LOAD_RES          = 0x0013,       // RoomServer->RoomSuper:加载返回
                        SCMDIN_MONITOR_DEPLOY_UNLOCK_REQ        = 0x0014,       // RoomSuper->RoomServer:请求解锁调度的频道 清空
                        SCMDIN_MONITOR_DEPLOY_UNLOCK_RES        = 0x0015,       // RoomServer->roomSuper:解锁调度的频道返回 清空返回
                        SCMDIN_MONITOR_MEDIA_LOAD_REQ           = 0x0016,       // RoomSuper->RoomServer:请求所有RoomMediaServer的负载
                        SCMDIN_MONITOR_MEDIA_LOAD_RES           = 0x0017,
                        SCMDIN_MONITOR_FORWARD_USERCMD_TO_SERVER        = 0x0018,
                        SCMDIN_MONITOR_FORWARD_USERCMD_TO_MONITOR       = 0x0019,
                };
                enum 
                { //CMDIN_MEDIARECORD
                        SCMDIN_MEDIARECORD_SAVE_FILE_URL        = 0x0001,
                        SCMDIN_MEDIARECORD_REPORT_STATUS        = 0x0002,       // media record->room super, 汇报当前录制情况
                        SCMDIN_MEDIARECORD_SCHEDULE_RECORD      = 0x0003,       // room super-> media record 通知media server录制
                        SCMDIN_MEDIARECORD_SCHEDULE_RECORD_RESPONSE     = 0x0004,       // media-> super 通知录制返回
                        SCMDIN_MEDIARECORD_SYNC_RECORDING_STATE = 0x0007,       // media -> super
                        SCMDIN_MEDIARECORD_DEPLOY_NOTIFICATION  = 0x0008,
                        SCMDIN_MEDIARECORD_DEPLOY_NOTIFICATION_ACK = 0x0009,
                        SCMDIN_MEDIARECORD_ERROR_REPORT         = 0x000A,
                };

                enum { /// CMDIN_ECHOSRV
                        SCMDIN_SYNC_IDC_ISP_LIST                = 0x0001,       // super sync idc-isp list to echoserver

                };

                //	cmd definition
                struct stStartUpRequest: t_NullCmd
                {
                        stStartUpRequest()
                                :
                                        t_NullCmd( CMDIN_STARTUP, SCMDIN_STARTUP_REQUEST )
                        {
                                wdServerType = 0;
                                wdServerID = 0;
                                bzero(pstrReserve, sizeof(pstrReserve));
                        }
                        WORD wdServerType;
                        WORD wdServerID;	    //if 0. not verify
                        char pstrReserve[16];           //reserved
                };
                struct stStartUpResponse: t_NullCmd
                {
                        stStartUpResponse()
                                :
                                        t_NullCmd( CMDIN_STARTUP, SCMDIN_STARTUP_RESPONSE )
                        {
                        }
                        ServerEntryNew entry;
                };
                struct stStartUpOK: t_NullCmd
                {
                        stStartUpOK()
                                :
                                        t_NullCmd( CMDIN_STARTUP, SCMDIN_STARTUP_OK )
                        {
                                wdServerID = 0;
                        }
                        WORD wdServerID;
                };
                struct stStartUpServerEntryNotifyMe: t_NullCmd
                {
                        stStartUpServerEntryNotifyMe()
                                :
                                        t_NullCmd( CMDIN_STARTUP, SCMDIN_STARTUP_SERVERENTRY_NOTIFY_ME )
                        {
                                size = 0;
                        }
                        WORD size;
                        ServerEntryNew entry[0];
                        DWORD getSize()
                        {
                                return sizeof( *this ) + size * sizeof( entry[0] );
                        }
                };
                struct stStartUpServerEntryNotifyOther: t_NullCmd {
                        stStartUpServerEntryNotifyOther()
                                :
                                        t_NullCmd( CMDIN_STARTUP, SCMDIN_STARTUP_SERVERENTRY_NOTIFY_OTHER )
                        {
                        }
                        ServerEntryNew entry;
                };
                struct stStartUpSyncTime: t_NullCmd
                {
                        stStartUpSyncTime()
                                :
                                        t_NullCmd( CMDIN_STARTUP, SCMDIN_SYNC_TIME )
                        {
                                qwTime = 0;
                        }
                        QWORD qwTime;
                };
                struct stStartUpSuperRequest: t_NullCmd
                {
                        stStartUpSuperRequest()
                                : t_NullCmd( CMDIN_STARTUP, SCMDIN_STARTUP_SUPER_REQUEST )
                        {
                                wdServerType = 0;
                                wdServerID = 0;
                                bzero(pstrReserve, sizeof(pstrReserve));
                        }
                        WORD wdServerType;
                        WORD wdServerID;	    //if 0. not verify
                        char pstrReserve[16];           //reserved
                };
                struct stStartUpSuperSuccess: t_NullCmd
                {
                        stStartUpSuperSuccess()
                                : t_NullCmd( CMDIN_STARTUP, SCMDIN_STARTUP_SUPER_SUCCESS )
                        {
                        }
                };
                struct stStartUpSuperFailure: t_NullCmd
                {
                        stStartUpSuperFailure()
                                : t_NullCmd( CMDIN_STARTUP, SCMDIN_STARTUP_SUPER_FAILURE )
                        {
                        }
                };
                struct stStartUpServerEntryNotifyByType: t_NullCmd
                {
                        stStartUpServerEntryNotifyByType()
                                : t_NullCmd( CMDIN_STARTUP, SCMDIN_STARTUP_SERVERENTRY_NOTIFY_BY_TYPE )
                        {
                                wdServerType = 0;
                                size = 0;
                        }

                        DWORD getSize() const
                        {
                                return sizeof( *this ) + size * sizeof( entry[0] );
                        }

                        WORD wdServerType;
                        WORD size;
                        ServerEntryNew entry[0];
                };
                struct stStartUpServerEntryNotifyById: t_NullCmd {
                        stStartUpServerEntryNotifyById()
                                : t_NullCmd( CMDIN_STARTUP, SCMDIN_STARTUP_SERVERENTRY_NOTIFY_BY_ID )
                        {
                        }

                        ServerEntryNew entry;
                };

                struct stForwardInnerCmdByID:
                        t_NullCmd
                {
                        stForwardInnerCmdByID()
                                :
                                        t_NullCmd( CMDIN_FORWARD, SCMDIN_FORWARD_INNERCMD_By_ID )
                        {
                                from_id_ = 0;
                                to_id_ = 0;
                                size_ = 0;
                        }
                        DWORD from_id_;
                        DWORD to_id_;
                        WORD size_;
                        BYTE data_[0];
                        DWORD getSize()
                        {
                                return sizeof( *this ) + size_ * sizeof( data_[0] );
                        }
                };
                struct stForwardInnerCmdByType:
                        t_NullCmd
                {
                        stForwardInnerCmdByType()
                                :
                                        t_NullCmd( CMDIN_FORWARD, SCMDIN_FORWARD_INNERCMD_By_TYPE )
                        {
                                from_id_ = 0;
                                to_type_ = 0;
                                size_ = 0;
                        }
                        DWORD from_id_;
                        DWORD to_type_;
                        WORD size_;
                        BYTE data_[0];
                        DWORD getSize()
                        {
                                return sizeof( *this ) + size_ * sizeof( data_[0] );
                        }
                };
                struct stSyncGatewayLoadRequest: t_NullCmd
                {
                        stSyncGatewayLoadRequest()
                                :
                                        t_NullCmd( CMDIN_SYNC, SCMDIN_SYNC_GATEWAY_LOAD_REQUEST )
                        {
                        }
                };
                struct stSyncGatewayLoadResponse: t_NullCmd
                {
                        stSyncGatewayLoadResponse()
                                :
                                        t_NullCmd( CMDIN_SYNC, SCMDIN_SYNC_GATEWAY_LOAD_RESPONSE )
                        {
                                server_id_ = 0;
                                load_ = 0;
                        }
                        DWORD server_id_;
                        DWORD load_;
                };
                struct stSyncGatewayLoadRemove: t_NullCmd
                {
                        stSyncGatewayLoadRemove()
                                :
                                        t_NullCmd( CMDIN_SYNC, SCMDIN_SYNC_GATEWAY_LOAD_REMOVE )
                        {
                                server_id_ = 0;
                        }
                        WORD server_id_;
                };
                struct stSyncSessionFunctionalitySupport: t_NullCmd
                {
                        stSyncSessionFunctionalitySupport()
                                : t_NullCmd(CMDIN_SYNC, SCMDIN_SYNC_SESSION_FUNCTIONALITY_SUPPORT)
                        {
                                size_ = 0;
                        }

                        uint32_t getSize() const
                        {
                                return sizeof(*this) + size_*sizeof(json_[0]);
                        }

                        uint16_t size_;
                        char json_[0];
                        // json_ = _functions(array)
                        // _function = func(uint) + extra(uint) + terminal(uint) + os(uint) + min_v(uint) + msgbox(string)
                };

                struct stRoomReqRoomLocation:
                        t_NullCmd
                {
                        stRoomReqRoomLocation()
                                :
                                        t_NullCmd( CMDIN_ROOM, SCMDIN_ROOM_REQ_ROOM_LOCATION )
                        {
                                room_id_ = 0;
                        }
                        DWORD room_id_;
                };
                struct stRoomResRoomLocation:
                        t_NullCmd
                {
                        stRoomResRoomLocation()
                                :
                                        t_NullCmd( CMDIN_ROOM, SCMDIN_ROOM_RES_ROOM_LOCATION )
                        {
                                room_id_ = 0;
                                room_server_id_ = 0;
                        }
                        DWORD room_id_;
                        WORD room_server_id_;
                };
                struct stRoomDelRoomLocation:
                        t_NullCmd
                {
                        stRoomDelRoomLocation()
                                :
                                        t_NullCmd( CMDIN_ROOM, SCMDIN_ROOM_DEL_ROOM_LOCATION )
                        {
                                room_id_ = 0;
                        }
                        DWORD room_id_;
                };
                struct stRoomReqLoad:
                        t_NullCmd
                {
                        stRoomReqLoad()
                                :
                                        t_NullCmd( CMDIN_ROOM, SCMDIN_ROOM_REQ_LOAD )
                        {
                                room_id_ = 0;
                        }
                        DWORD room_id_;
                };
                struct stRoomResLoad:
                        t_NullCmd
                {
                        stRoomResLoad()
                                :
                                        t_NullCmd( CMDIN_ROOM, SCMDIN_ROOM_RES_LOAD )
                        {
                                room_id_ = 0;
                                ret_code_ = 0;
                        }
                        DWORD room_id_;
                        BYTE ret_code_; //0-fail, 1-success
                };
                struct stRoomReqRoomMediaMap:
                        t_NullCmd
                {
                        stRoomReqRoomMediaMap()
                                :
                                        t_NullCmd( CMDIN_ROOM, SCMDIN_ROOM_REQ_ROOMMEDIAMAP )
                        {
                        }
                };
                struct stRoomResRoomMediaMap:
                        t_NullCmd
                {
                        stRoomResRoomMediaMap()
                                :
                                        t_NullCmd( CMDIN_ROOM, SCMDIN_ROOM_RES_ROOMMEDIAMAP )
                        {
                                size_ = 0;
                        }
                        WORD size_;
                        struct
                        {
                                WORD room_server_id_;
                                WORD media_server_id_;
                        } list_[0];
                        DWORD getSize()
                        {
                                return sizeof( *this ) + size_ * sizeof( list_[0] );
                        }
                };
                struct stRoomListSyncReq:
                        t_NullCmd
                {
                        stRoomListSyncReq()
                                :
                                        t_NullCmd( CMDIN_ROOM, SCMDIN_ROOM_ROOMLIST_SYNC_REQ )
                        {
                        }
                };
                struct stRoomListSyncRes:
                        t_NullCmd
                {
                        stRoomListSyncRes()
                                :
                                        t_NullCmd( CMDIN_ROOM, SCMDIN_ROOM_ROOMLIST_SYNC_RES )
                        {
                                room_num_ = 0;
                        }
                        WORD room_num_;
                        DWORD room_list_[0];
                        DWORD getSize()
                        {
                                return sizeof( *this ) + room_num_ * sizeof( room_list_[0] );
                        }
                };
                struct stRoomRedistributeRoomReq:
                        t_NullCmd
                {
                        stRoomRedistributeRoomReq()
                                :
                                        t_NullCmd( CMDIN_ROOM, SCMDIN_ROOM_REDISTRIBUTE_ROOM_REQ )
                        {
                                room_id_ = 0;
                        }
                        DWORD room_id_;
                };
                struct stRoomRedistributeRoomRes:
                        t_NullCmd
                {
                        stRoomRedistributeRoomRes()
                                :
                                        t_NullCmd( CMDIN_ROOM, SCMDIN_ROOM_REDISTRIBUTE_ROOM_RES )
                        {
                                room_id_ = 0;
                                ret_code_ = 0;
                        }
                        DWORD room_id_;
                        BYTE ret_code_; //0-fail 1-success
                };
                struct stRoomUpdateUserRole:
                        t_NullCmd
                {
                        public:
                                stRoomUpdateUserRole()
                                        : t_NullCmd(CMDIN_ROOM, SCMDIN_ROOM_UPDATE_USER_ROLE)
                                {
                                        room_id_ = 0;
                                        user_id_ = 0;
                                        role_ = 0;
                                }
                                void setRoomID(const DWORD &id)
                                {
                                        room_id_ = id;
                                }
                                void setUserID(const DWORD &id)
                                {
                                        user_id_ = id;
                                }
                                void setRole(const BYTE &role)
                                {
                                        role_ = role;
                                }
                                DWORD getRoomID() const
                                {
                                        return room_id_;
                                }
                                DWORD getUserID() const
                                {
                                        return user_id_;
                                }
                                BYTE getRole() const
                                {
                                        return role_;
                                }
                        private:
                                DWORD room_id_;
                                DWORD user_id_;
                                BYTE role_;
                };
                struct stRoomResInnerNetList:
                        t_NullCmd
                {
                        stRoomResInnerNetList():
                                t_NullCmd(CMDIN_ROOM, SCMDIN_ROOM_RES_INNER_NET_LIST)
                        {
                                size_ = 0;
                        }
                        DWORD getSize() const
                        {
                                return sizeof(*this) + size_ *sizeof(list_[0]);
                        }
                        WORD size_;
                        WORD list_[0];
                };
                struct stRoomEVALTimeNotify:
                        t_NullCmd
                {
                        stRoomEVALTimeNotify()
                                : t_NullCmd(CMDIN_ROOM, SCMDIN_ROOM_EVAL_TIME_NOTIFY)
                        {
                                minutes_enable_ = 0;
                                minutes_disable_ = 0;
                        }

                        uint16_t minutes_enable_;
                        uint16_t minutes_disable_;
                };

                /// RoomSuper <-> RoomMediaServer
                struct stRMediaHeartBeat:
                        t_NullCmd
                {
                        stRMediaHeartBeat():
                                t_NullCmd(CMDIN_ROOMMEDIA, SCMDIN_RMEDIA_HEARTBEAT)
                        { }
                };

                /*-------------------------------*/
                struct stMonitorCmd:
                        t_NullCmd
                {
                        stMonitorCmd(const WORD subcmd)
                                : t_NullCmd(CMDIN_MONITOR, subcmd)
                        {
                                monitor_id_ = 0;
                        }
                        void setMonitorID(const DWORD &mid)
                        {
                                monitor_id_ = mid;
                        }
                        DWORD getMonitorID() const
                        {
                                return monitor_id_;
                        }
                        DWORD monitor_id_;
                };
                struct stMonitorUserLocationReq:
                        stMonitorCmd
                {
                        stMonitorUserLocationReq()
                                : stMonitorCmd( SCMDIN_MONITOR_USER_LOCATION_REQ )
                        {
                                user_id_ = 0;
                                bzero( user_name_, sizeof( user_name_ ) );
                        }
                        void setUserID(const DWORD &uid)                { user_id_ = uid; }
                        void setUserName(const std::string &uname)      { strncpy(user_name_, uname.c_str(), MAX_ACCOUNT_SIZE); }
                        DWORD getUserID()                               const { return user_id_; }
                        const char *getUserName()                       const { return user_name_; }

                        DWORD user_id_;
                        char user_name_[MAX_ACCOUNT_SIZE + 1];
                };
                struct stMonitorUserLocationRes:
                        stMonitorCmd
                {
                        stMonitorUserLocationRes()
                                : stMonitorCmd( SCMDIN_MONITOR_USER_LOCATION_RES )
                        {
                                user_id_ = 0;
                                bzero( user_name_, sizeof( user_name_ ) );
                                user_ip_ = 0;
                                session_id_ = 0;
                                gateway_id_ = 0;
                        }
                        void setUserID(const DWORD &uid)        { user_id_ = uid; }
                        void setUserName(const std::string &uname)      { strncpy(user_name_, uname.c_str(), MAX_ACCOUNT_SIZE); }
                        void setUserIP(const DWORD &uip)        { user_ip_ = uip; }
                        void setSessionID(const WORD &sid)      { session_id_ = sid; }
                        void setGatewayID(const WORD &gid)      { gateway_id_ = gid; }
                        void setRoomID(const DWORD &roomid)     { room_id_ = roomid; }
                        DWORD getUserID()       const { return user_id_; }
                        const char *getUserName()     const { return user_name_; }
                        DWORD getUserIP()       const { return user_ip_; }
                        WORD getSessionID()     const { return session_id_; }
                        WORD getGatewayID()     const { return gateway_id_; }
                        DWORD getRoomID()       const { return room_id_; }


                        DWORD user_id_;         //用户id
                        char user_name_[MAX_ACCOUNT_SIZE + 1];
                        DWORD user_ip_;         //用户的ip
                        WORD session_id_;       //用户所在的session
                        WORD gateway_id_;       //用户所在的gateway
                        DWORD room_id_;         //用户所在的房间
                };
                struct stMonitorGatewayServerLoadReq:
                        stMonitorCmd
                {
                        stMonitorGatewayServerLoadReq()
                                : stMonitorCmd( SCMDIN_MONITOR_GATEWAYSERVER_LOAD_REQ )
                        {
                        }
                };
                struct stMonitorGatewayServerLoadRes:
                        stMonitorCmd
                {
                        stMonitorGatewayServerLoadRes()
                                : stMonitorCmd( SCMDIN_MONITOR_GATEWAYSERVER_LOAD_RES )
                        {
                                gateway_id_ = 0;
                                load_max_ = 0;
                                load_cur_ = 0;
                        }
                        WORD gateway_id_;
                        DWORD load_max_;        //最大负载
                        DWORD load_cur_;        //当前负载
                };
                struct stMonitorSessionServerLoadReq:
                        stMonitorCmd
                {
                        stMonitorSessionServerLoadReq()
                                : stMonitorCmd( SCMDIN_MONITOR_SESSIONSERVER_LOAD_REQ )
                        {
                        }
                };
                struct stMonitorSessionServerLoadRes:
                        stMonitorCmd
                {
                        stMonitorSessionServerLoadRes()
                                : stMonitorCmd( SCMDIN_MONITOR_SESSIONSERVER_LOAD_RES )
                        {
                                session_id_ = 0;
                                load_max_ = 5000;
                                load_cur_ = 0;
                        }
                        WORD session_id_;
                        DWORD load_max_;        //最大负载
                        DWORD load_cur_;        //当前负载
                };
                struct stMonitorRoomServerLoadReq:
                        stMonitorCmd
                {
                        stMonitorRoomServerLoadReq()
                                : stMonitorCmd( SCMDIN_MONITOR_ROOMSERVER_LOAD_REQ )
                        {
                        }
                };
                struct stMonitorRoomServerLoadRes:
                        stMonitorCmd
                {
                        stMonitorRoomServerLoadRes()
                                : stMonitorCmd( SCMDIN_MONITOR_ROOMSERVER_LOAD_RES )
                        {
                                monitor_id_ = 0;
                                room_server_ = 0;
                                room_num_ = 0;
                        }
                        DWORD monitor_id_;      //monitor client id
                        WORD room_server_;     //room server id
                        DWORD room_num_;
                        struct
                        {
                                DWORD roomid;   //room
                                char roomname[MAX_ROOM_NAME_SIZE + 1];
                                DWORD membernum;   //real member num
                                WORD roomtype;
                                DWORD autoghostnum;
                                DWORD ghostnum;
                                DWORD medianum;
                        } room_list_[0];
                        DWORD getSize()
                        {
                                return sizeof( *this ) + room_num_ * sizeof( room_list_[0] );
                        }
                };
                struct stMonitorUpdateRoomUserRole:
                        stMonitorCmd
                {
                        stMonitorUpdateRoomUserRole()
                                : stMonitorCmd( SCMDIN_MONITOR_UPDATE_ROOM_USER_ROLE )
                        {
                                room_id_ = 0;
                                user_id_ = 0;
                                role_type_ = eRoomAuthority_Null;
                                operate_type_ = 0;
                        }
                        DWORD room_id_;
                        DWORD user_id_;
                        BYTE role_type_;        //eRoomAuthority
                        BYTE operate_type_;     //暂未使用
                };
                struct stRoomDeployLockReq:
                        stMonitorCmd
                {
                        stRoomDeployLockReq():
                                stMonitorCmd(SCMDIN_MONITOR_DEPLOY_LOCK_REQ)
                        {
                                room_id_ = 0;
                        }
                        DWORD room_id_;
                };
                struct stRoomDeployLockRes:
                        stMonitorCmd
                {
                        stRoomDeployLockRes():
                                stMonitorCmd(SCMDIN_MONITOR_DEPLOY_LOCK_RES)
                        {
                                room_id_ = 0;
                                ret_ = 0;
                        }
                        DWORD room_id_;
                        BYTE ret_; //0-fail 1-success
                };
                struct stRoomDeployLoadReq:
                        stMonitorCmd
                {
                        stRoomDeployLoadReq():
                                stMonitorCmd(SCMDIN_MONITOR_DEPLOY_LOAD_REQ)
                        {
                                room_id_ = 0;
                        }
                        DWORD room_id_;
                };
                struct stRoomDeployLoadRes:
                        stMonitorCmd
                {
                        stRoomDeployLoadRes():
                                stMonitorCmd(SCMDIN_MONITOR_DEPLOY_LOAD_RES)
                        {
                                room_id_ = 0;
                                ret_ = 0;
                        }
                        DWORD room_id_;
                        BYTE ret_;
                };
                struct stRoomDeployUnlockReq:
                        stMonitorCmd
                {
                        stRoomDeployUnlockReq():
                                stMonitorCmd(SCMDIN_MONITOR_DEPLOY_UNLOCK_REQ)
                        {
                                room_id_ = 0;
                                clear_ = 0;
                        }
                        DWORD room_id_;
                        BYTE clear_;
                };
                struct stRoomDeployUnlockRes:
                        stMonitorCmd
                {
                        stRoomDeployUnlockRes():
                                stMonitorCmd(SCMDIN_MONITOR_DEPLOY_UNLOCK_RES)
                        {
                                room_id_ = 0;
                                ret_ = 0;
                        }
                        DWORD room_id_;
                        BYTE ret_;
                };
                struct stMonitorMediaLoadReq:
                        stMonitorCmd
                {
                        stMonitorMediaLoadReq():
                                stMonitorCmd(SCMDIN_MONITOR_MEDIA_LOAD_REQ)
                        {
                        }
                };
                struct stMonitorMediaLoadRes:
                        stMonitorCmd
                {
                        public:
                                stMonitorMediaLoadRes()
                                        : stMonitorCmd(SCMDIN_MONITOR_MEDIA_LOAD_RES)
                                {
                                        num_ = 0;
                                }
                                struct stLoadInfo {
                                        WORD mediaserverid;
                                        DWORD mediaserverload;
                                };
                                void setNum(const WORD &num)
                                {
                                        num_ = num;
                                }
                                WORD getNum() const
                                {
                                        return num_;
                                }
                                stLoadInfo &getElement(const WORD &n)
                                {
                                        return list_[n];
                                }
                                void addElement(const WORD &serverid, const DWORD &serverload)
                                {
                                        list_[num_].mediaserverid = serverid;
                                        list_[num_].mediaserverload = serverload;
                                        num_++;
                                }
                                DWORD getSize()
                                {
                                        return sizeof(*this)+num_*sizeof(list_[0]);
                                }

                        private:
                                WORD num_;
                                stLoadInfo list_[0];
                };
                struct stMonitorForwardUserCmdToServer:
                        stMonitorCmd
                {
                        stMonitorForwardUserCmdToServer()
                                : stMonitorCmd(SCMDIN_MONITOR_FORWARD_USERCMD_TO_SERVER)
                        {
                                monitor_id_ = 0;
                                size_ = 0;
                        }

                        const WORD getSize() const
                        {
                                return sizeof(*this) + size_ * sizeof(data_[0]);
                        }

                        WORD monitor_id_;
                        WORD size_;
                        char data_[0];
                };
                struct stMonitorForwardUserCmdToMonitor:
                        stMonitorCmd
                {
                        stMonitorForwardUserCmdToMonitor()
                                : stMonitorCmd(SCMDIN_MONITOR_FORWARD_USERCMD_TO_MONITOR)
                        {
                                monitor_id_ = 0;
                                size_ = 0;
                        }

                        const WORD getSize() const
                        {
                                return sizeof(*this) + size_ * sizeof(data_[0]);
                        }

                        WORD monitor_id_;
                        WORD size_;
                        char data_[0];
                };

                struct stMediaRecordSaveFileUrl:
                        t_NullCmd
                {
                        stMediaRecordSaveFileUrl():
                                t_NullCmd(CMDIN_MEDIARECORD, SCMDIN_MEDIARECORD_SAVE_FILE_URL)
                        {
                                filetype = 0;
                                recording_id_ = 0;
                                bzero(fileurl, sizeof(fileurl));
                        }
                        BYTE filetype; //0-txt 1-mp3
                        DWORD recording_id_;
                        char fileurl[256];
                };
                        
                struct stMediaRecordReportStatus :
                        t_NullCmd
                {
                        stMediaRecordReportStatus() :
                                t_NullCmd(CMDIN_MEDIARECORD, SCMDIN_MEDIARECORD_REPORT_STATUS)
                        {
                                srv_id = 0;
                                recording_cnt = 0;
                                pending_cnt = 0;
                        }
                        
                        uint16_t srv_id;
                        uint32_t recording_cnt;
                        uint32_t pending_cnt;                       
                };

                struct stMediaRecordStartRecord :
                        t_NullCmd
                {
                        stMediaRecordStartRecord() :
                                t_NullCmd(CMDIN_MEDIARECORD, SCMDIN_MEDIARECORD_SCHEDULE_RECORD)
                        {
                                record_id = 0;
                                room_id = 0;
                                start_time = 0;
                                stop_time = 0;
                                srv_id = 0;
                                courseware_id = 0;
                                lesson_id = 0;
                                bzero(event_name, sizeof(event_name));
                        }

                        uint32_t record_id;
                        uint32_t room_id;
                        uint32_t start_time;
                        uint32_t stop_time;
                        uint32_t srv_id;
                        uint32_t courseware_id;
                        uint32_t lesson_id;
                        char event_name[256+1];
                };

                struct stMediaRecordStartRecordResponse :
                        t_NullCmd
                {
                        stMediaRecordStartRecordResponse() :
                                t_NullCmd(CMDIN_MEDIARECORD, SCMDIN_MEDIARECORD_SCHEDULE_RECORD_RESPONSE)
                        {
                                record_id = 0;
                                ret_code = 0;
                        }
                        uint32_t record_id;
                        int32_t ret_code;
                };

                struct stMediaRecordSyncRecordingState:
                        t_NullCmd
                {
                        stMediaRecordSyncRecordingState()
                                : t_NullCmd(CMDIN_MEDIARECORD, SCMDIN_MEDIARECORD_SYNC_RECORDING_STATE)
                        {
                                recording_id_ = 0;
                                state_ = 0;
                        }

                        uint32_t recording_id_;
                        uint8_t state_;         // 0:待录制 1:录制中 2:录制完成 3:正在转换xml 4:转换xml完成 5:正在上传文件 6:文件上传成功
                };

                struct stMediaRecordRoomDeployNotification :
                        t_NullCmd
                {
                        stMediaRecordRoomDeployNotification() :
                            t_NullCmd(CMDIN_MEDIARECORD, SCMDIN_MEDIARECORD_DEPLOY_NOTIFICATION)
                        {
                            recording_id = 0;
                            room_id = 0;
                            srv_id = 0;
                        }
                        
                        uint32_t recording_id;
                        uint32_t room_id;
                        uint32_t srv_id;
                };

                struct stMediaRecordRoomDeployNotificationAck :
                        t_NullCmd
                {
                        stMediaRecordRoomDeployNotificationAck() :
                            t_NullCmd(CMDIN_MEDIARECORD, SCMDIN_MEDIARECORD_DEPLOY_NOTIFICATION_ACK)
                        {
                            recording_id = 0;
                            room_id = 0;
                            srv_id = 0;
                        }

                        uint32_t recording_id;
                        uint32_t room_id;
                        uint32_t srv_id;
                };

                struct stMediaRecordErrorReport :
                        t_NullCmd
                {
                        stMediaRecordErrorReport() :
                                t_NullCmd(CMDIN_MEDIARECORD, SCMDIN_MEDIARECORD_ERROR_REPORT)
                        {
                        }

                        uint32_t getSize() const
                        {
                                return sizeof(*this) + size_ * sizeof(data_[0]);
                        }

                        uint32_t recording_id_;
                        uint16_t size_;
                        char data_[0];          // error msg
                };
                struct stSyncIdcIspList:
                        t_NullCmd
                {
                        stSyncIdcIspList():
                                t_NullCmd(CMDIN_ECHOSRV, SCMDIN_SYNC_IDC_ISP_LIST)
                        {
                        }
                        uint32_t get_len()
                        {
                                return sizeof(*this) + size*sizeof(list[0]);
                        }
                        uint16_t size;
                        struct {
                                uint16_t idc;
                                uint16_t isp;
                        } list[0];
                };
        };//namespace Super
};//namespace Cmd

#pragma pack() //pack(1)
#endif //SUPER_COMMAND_H_
